This notebook explores the National Drug Code file from FDA.gov. The zip file was last available here.
In order to run this example, download the NDC.zip file and put product.txt in the same folder as this notebook.
In [1]:
# imports
import sys
sys.path.append('..')
from IPython.display import HTML
from nailfile import readers
from nailfile import nailfile
In [2]:
# run this to load the file into an in-memory SQLite database
reader = readers.CsvReader('product.txt', table_name='products', delimiter='\t')
loader = nailfile.DataLoader()
ds = loader.load(reader)
In [3]:
# query away!
# get the top drug manufacturers
sql = """
select LABELERNAME, count(*) from products group by LABELERNAME order by 2 desc limit 10
"""
results = ds.fetchall(sql)
h = HTML(nailfile.to_html(results))
h
Out[3]:
In [ ]: